<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
CesiumTest01.html

<div id="cesiumContainer">

</div>

<!--<script src="https://unpkg.com/cesium@1.100.0/Build/Cesium/Cesium.js"></script>-->
<script type="module">
    console.log('加载文件 ‘CesiumTest01.html');

    //导入LCCRender库
    import { LCCRender } from './lib/LCC-Web-0.4.1/lcc-0.4.1.js'
    console.log('LCCRender 模块内容:', LCCRender);

    //导入Cesium库
    import * as Cesium from 'https://esm.sh/cesium';
    console.log('Cesium 模块内容:', Cesium);

    const viewer = new Cesium.Viewer("cesiumContainer", {
        orderIndependentTranslucency: false,  //次序无关渲染需关掉
        useDefaultRenderLoop: true,
        resolutionScale: window.devicePixelRatio,
    });


    //得到局部坐标原点的全局坐标
    var cart3 = Cesium.Ellipsoid.WGS84.cartographicToCartesian(Cesium.Cartographic.fromDegrees(114.059, 22.5429, 1));
    //modelMatrix为局部坐标的z轴垂直于地表，局部坐标的y轴指向正北的4x4变换矩阵
    var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(cart3);

    // const dataPathResult = "http://localhost:3000/data/GCC/LCC_Results/GCC.lcc";
    const dataPathResult = "http://localhost:3000/data/GCC/OFFICE/LCC_Results/办公室最新.lcc";
    // const dataPathResult = "http://localhost:3000/data/LEGOPanda/meta.lcc";
    // const dataPathResult = "./data/LEGOPanda/meta.lcc";

    let lccObject = LCCRender.load({
        camera: viewer.camera,
        scene: viewer.scene,
        dataPath: dataPathResult,
        renderLib: Cesium,
        canvas: viewer.scene.canvas,
        modelMatrix: modelMatrix, //模型的变换矩阵，没有变换矩阵的话，模型位置一般在地心,如果采集的LCC数据是RTK真实坐标数据，这个modelMatrix无需设置，设置也会不生效。
    }, function (mesh){
        console.log('模型加载完成 ', mesh)
    }, function (percent) {
        console.log('模型已加载：' + percent * 100 + '%' )
    }, function () {
        console.log('模型加载失败')
    });

    //相机飞向指定位置
    viewer.scene.camera.flyTo({
        destination: new Cesium.Cartesian3(
            -2402935.756416574,
            5381763.382104505,
            2429866.1827734606
        ),
        orientation: {
            up: new Cesium.Cartesian3(
                -0.2689305478318041,
                0.8007469133573548,
                0.5352389570944504
            ),
            direction: new Cesium.Cartesian3(
                0.5919220429524843,
                -0.30097776828562117,
                0.7476902286808116
            )
        }
    })

</script>

</body>
</html>